float4x4 World;
float4x4 View;
float4x4 Projection;

float time;

Texture ColorTexture;

Texture texturaOrigem;
Texture texturaDestino;


sampler colorTextureSampler = sampler_state
{
	texture = <ColorTexture>;
	magfilter = LINEAR;
	minfilter = LINEAR;
	mipfilter = LINEAR;
};

sampler texturaOrigemSampler = sampler_state
{
	texture = <texturaOrigem>;
	magfilter = LINEAR;
	minfilter = LINEAR;
	mipfilter = LINEAR;
	AddressU = clamp;
	AddressV = clamp;
};

sampler texturaDestinoSampler = sampler_state
{
	texture = <texturaDestino>;
	magfilter = LINEAR;
	minfilter = LINEAR;
	mipfilter = LINEAR;
	AddressU = clamp;
	AddressV = clamp;
};

struct VertexShaderInput
{
    float4 Position : POSITION0;
	float2 textureCoord : TEXCOORD0;

    // TODO: add input channels such as texture
    // coordinates and vertex colors here.
};

struct VertexShaderOutput
{
    float4 Position : POSITION0;
	float2 textureCoord : TEXCOORD0;

    // TODO: add vertex shader outputs such as colors and texture
    // coordinates here. These values will automatically be interpolated
    // over the triangle, and provided as input to your pixel shader.
};

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
    VertexShaderOutput output;

    float4 worldPosition = mul(input.Position, World);
    float4 viewPosition = mul(worldPosition, View);
    output.Position = mul(viewPosition, Projection);
	
	output.textureCoord = input.textureCoord;
    // TODO: add your vertex shader code here.

    return output;
}

float4 Negative(VertexShaderOutput input) : COLOR0
{
    // TODO: add your pixel shader code here.
	float4 output;
	output = 1 - tex2D(colorTextureSampler, input.textureCoord);

    return output;
}

float4 Morphing(VertexShaderOutput input) : COLOR0
{
    // TODO: add your pixel shader code here.
	
	float4 origem = tex2D(texturaOrigemSampler, input.textureCoord);
	float4 destino = tex2D(texturaDestinoSampler, input.textureCoord);

	float4 output = origem * (1 - time) + destino * time;
    return output;
}

technique MorphingTechnique
{
    pass Pass1
    {
        // TODO: set renderstates here.

        VertexShader = compile vs_2_0 VertexShaderFunction();
        PixelShader = compile ps_2_0 Morphing();
    }
}


technique NegativeTechnique
{
    pass Pass1
    {
        // TODO: set renderstates here.

        VertexShader = compile vs_2_0 VertexShaderFunction();
        PixelShader = compile ps_2_0 Negative();
    }
}